﻿using UnityEngine;

namespace Yoozoo.Modules.InnerCity
{
    public class CollectAction : ActionBase
    {
        private float totalTime;
        private float curTime;
        
        protected override StateAction state
        {
            get => StateAction.Collect;
        }

        public override void Init(CityUnit owner)
        {
            base.Init(owner);
        }

        public override void Enter(object arg = null)
        {
            Debug.Log("进入了采集状态");

            this.totalTime = (float) arg;
            this.curTime = 0;
            this.owner.PlayCollectAni();
        }

        public override void Play()
        {
            this.curTime += Time.deltaTime;
            if (this.curTime >= this.totalTime)
                this.owner.OnCollectEnd();
        }

        public override void Exit()
        {
            Debug.Log("退出了采集状态");
            
            base.Exit();
        }
    }
}